<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Star(uname, age) {
        this.uname = uname
        this.age = age
      }
      Star.prototype.sing = function() {
        console.log('只因你太美')
      }
      const cxk = new Star('ikun', 28)
      const cxk1 = new Star('ikun1', 218)
      // console.log(cxk)
      // console.log(cxk1)
      // cxk.sing()
      // cxk1.sing()
      // console.log(cxk.sing === cxk1.sing)
      // 实例对象的__proto__属性指向构造函数的原型对象
      console.log(cxk.__proto__ === Star.prototype) //true
      // 原型对象上的constructor属性指向构造函数
      console.log(Star.prototype.constructor === Star) //true
      // cxk没有constructor属性，在运行上找，原型上有cxk可以用
      console.log(cxk.constructor === Star) //true
      // 构造函数的原型对象的__proto__属性指向Object的原型对象
      console.log(cxk.__proto__.__proto__ === Object.prototype) //true
      // 构造函数的原型对象的__proto__属性的constructor属性指向Object构造函数
      console.log(cxk.__proto__.__proto__.constructor === Object) //true
      //  Object的原型对象的__proto__属性指向null
      console.log(cxk.__proto__.__proto__.__proto__ === null) //true
    </script>
  </body>
</html>
